Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decoupling ActiveSupport from ActionView #6526

Merged
merged 1 commit into from May 29, 2012
Merged

Decoupling ActiveSupport from ActionView #6526

merged 1 commit into from May 29, 2012

Conversation

amutz
Copy link
Contributor

@amutz amutz commented May 29, 2012

Hi,

I'm interested in using the ActiveSupport::Testing::Performance module and was surprised to see that it requires and calls code from ActionView. I'd like to use this module in a context without ActionView, and now that we've moved NumberHelpers to ActiveSupport (#6315), we can do this.

In this pull request I'm changing ActiveSupport::Testing::Performance to use ActiveSupport::NumberHelper instead of ActionView::Helpers::NumberHelper. Also, to my knowledge this logic was untested, so I have added tests for the formatting logic (which pass before and after the code change).

Any and all feedback is welcome.

Thanks!
-Andrew.

module ActiveSupport
module Testing
module Performance
class PerformanceTest < ActiveSupport::TestCase

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's no need for the Performance module, wdyt?

@carlosantoniodasilva
Copy link
Member

Other than that, looks 👍 to me, thanks!

@amutz
Copy link
Contributor Author

amutz commented May 29, 2012

I needed some module because I didn't want the class name PerformanceTest polluting things globally. I chose to put it in the module ActiveSupport::Testing::Performance, just because that's also the name of the module whose logic it is testing.

It works just as well without it however, i'll update the PR to remove the Performance module and squash it.

Thanks for the feedback!

@carlosantoniodasilva
Copy link
Member

Sure, your idea is definitely a good logic to follow, I agree about having some module namespacing in such scenarios. I just thought that having both Performance and PerformanceTest under the same level would be enough and unlikely to collide with anything else. Thanks!

@amutz
Copy link
Contributor Author

amutz commented May 29, 2012

Ok, I have removed the extra module and squashed it. Let me know if you'd like any other changes. :)

assert_equal "-5000 ms", time_metric.format(-5)
end

def test_amount_time

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed both tests are named the same test_amount_time :)

@carlosantoniodasilva
Copy link
Member

Also, it seems there's a missing require (totally unrelated, but lets take the opportunity): active_support/core_ext/module/delegation. Can you add it, please?

I get this when running that single file:

/active_support/testing/performance.rb:96:in `<class:Performer>': undefined method `delegate' for ActiveSupport::Testing::Performance::Performer:Class (NoMethodError)`

Thanks.

@amutz
Copy link
Contributor Author

amutz commented May 29, 2012

Great catch on the methods names! I've fixed them.

I've also added the missing require and the file loads fine now individually.

Let me know if you'd like any other changes. Thanks!

@carlosantoniodasilva
Copy link
Member

Looking great, thank you.

carlosantoniodasilva added a commit that referenced this pull request May 29, 2012
…actionivew

Decoupling ActiveSupport from ActionView
@carlosantoniodasilva carlosantoniodasilva merged commit d4a7dee into rails:master May 29, 2012
@josevalim
Copy link
Contributor

This is awesome! 👍 👍 👍 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants